import { createStore } from 'vuex'

export default createStore({
  state: {
    username: '',
    islogin: false,
    Authorization: sessionStorage.getItem('Authorization') ? sessionStorage.getItem('Authorization') : '',
    // 导航条, 布局风格, default(白色) / colorful(鲜艳)
    navbarLayoutType: 'default',
    // 侧边栏, 布局皮肤, default(白色) / dark(黑色)
    sidebarLayoutSkin: 'default',
    // 布局, 布局皮肤, default(默认显示) / top(顶部显示)
    layoutType: 'default',
    // 侧边栏, 折叠状态
    sidebarFold: false,
    // 侧边栏, 菜单
    sidebarMenuList: [],
    // 顶部导航栏
    topSidebarMenuList: [],
    activeIndex: [],
    sidebarMenuActiveName: '',
    // 内容, 是否需要刷新
    contentIsNeedRefresh: false,
    // 内容, 标签页(默认添加首页)
    contentTabs: [
      {
        ...window.SITE_CONFIG.contentTabDefault,
        name: 'home',
        title: 'home'
      }
    ],
    contentTabsActiveName: 'home',
    menuList: [
      {
        id: 'w_001',
        pid: '0',
        name: '权限管理',
        url: null,
        type: 0,
        icon: 'el-icon-setting',
        permissions: null,
        sort: 0,
        createDate: '2021-07-25 22:02:39',
        parentName: null,
        children: [{
          id: 'w_001_01',
          pid: 'w_001',
          name: '用户管理',
          url: 'sys/user',
          type: 0,
          icon: 'el-icon-setting',
          permissions: null,
          sort: 0,
          createDate: '2021-07-25 22:02:39',
          parentName: null,
          children: []
        }, {
          id: 'w_001_02',
          pid: 'w_001',
          name: '菜单管理',
          url: 'sys/menu',
          type: 0,
          icon: 'el-icon-setting',
          permissions: null,
          sort: 0,
          createDate: '2021-07-25 22:02:39',
          parentName: null,
          children: []
        }, {
          id: 'w_001_03',
          pid: 'w_001',
          name: '角色管理',
          url: 'sys/role',
          type: 0,
          icon: 'el-icon-setting',
          permissions: null,
          sort: 0,
          createDate: '2021-07-25 22:02:39',
          parentName: null,
          children: []
        }, {
          id: 'w_001_04',
          pid: 'w_001',
          name: '部门管理',
          url: 'sys/dept',
          type: 0,
          icon: 'el-icon-setting',
          permissions: null,
          sort: 0,
          createDate: '2021-07-25 22:02:39',
          parentName: null,
          children: []
        }]
      },
      {
        id: 'w_002',
        pid: '0',
        name: '业务管理',
        url: null,
        type: 0,
        icon: 'el-icon-setting',
        permissions: null,
        sort: 0,
        createDate: '2021-07-25 22:02:39',
        parentName: null,
        children: [{
          id: 'w_002_01',
          pid: 'w_002',
          name: '业务管理1',
          url: 'sys/yw1',
          type: 0,
          icon: 'el-icon-setting',
          permissions: null,
          sort: 0,
          createDate: '2021-07-25 22:02:39',
          parentName: null,
          children: []
        }, {
          id: 'w_002_02',
          pid: 'w_002',
          name: '业务管理2',
          url: 'sys/yw2',
          type: 0,
          icon: 'el-icon-setting',
          permissions: null,
          sort: 0,
          createDate: '2021-07-25 22:02:39',
          parentName: null,
          children: []
        }]
      }
    ]
  },
  getters: {
    getusername: (state) => state.username,
    getAuthorization: (state) => state.Authorization,
    getislogin: (state) => state.islogin
  },
  mutations: {
    setusername (state, username) {
      state.username = username
    },
    setAuthorization (state, Authorization) {
      state.Authorization = Authorization
      sessionStorage.setItem('Authorization', Authorization)
    },
    setislogin (state, islogin) {
      state.islogin = islogin
    }
  },
  actions: {
    setUser (context) {
      context.commit('setUser')
    },
    setLoginStatus (context) {
      context.commit('setLoginStatus')
    }
  },
  modules: {
  }
})
